#include <iostream>
#include <vector>
using namespace std;
#define int long long
 
signed main()
{
    int n = 0;
    cin >> n;
    vector<int> arr(n + 1);
    for(int i = 1; i <= n; ++i)
    {
        cin >> arr[i];
    }
    vector<int> dp(n + 1);
    for(int i = 3; i <= n; ++i)
    {
        dp[i] = max(dp[i - 1], dp[i - 3] + arr[i - 1]); // 不拿和拿
    }
    cout << dp[n] << endl;
    return 0;
}